package com.common.model;

import lombok.Data;

/**
 * 边
 *
 * @author think
 * @version 1.0.0
 * @since 2020/2/18
 */
@Data
public class Edge implements Comparable<Edge> {

    private int srcNode;
    private int dstNode;
    private int weight;
    private Edge nextEdge;

    public Edge(int srcNode, int dstNode, int weight) {
        this.srcNode = srcNode;
        this.dstNode = dstNode;
        this.weight = weight;
    }

    public int getOther(int x) {
        return x == srcNode ? dstNode : srcNode;
    }

    @Override
    public int compareTo(Edge o) {
        return Double.compare(this.getWeight(), o.getWeight());
    }
}
